package com.threeti.mecool.core.application.acl;

import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.threeti.mecool.core.domain.model.acl.User;

public interface UserService extends UserDetailsService {

  /** SpringSecuity方法实现 */
  @Override
  UserAdapter loadUserByUsername(String loginName) throws UsernameNotFoundException, DataAccessException;

  /**
   * 用户注册<p>
   * 
   * 内部实现会在openfire消息服务器上注册一个ID，如果失败，目前暂时保持静默
   */
  User register(User user);
  
  User getUserFromSession();
  
  User getCurrentUserWithPermissionRoleAndEntries();
  
  /** 
   * 从系统中删除用户<p>
   * 
   * 1.需要级联删除用户的ACL信息
   */
  void removeUserFromSystem(User user);
  
  /** 
   * 更新用户<p>
   * 
   * 1.如果角色和ACL信息有所变化，需要级联更新用户的ACL信息
   */
  void updateUserBy(Long userId, Long oldRoleIdOfUser, User userWithDataNeedToBeUpdated);

}
